<!--edit by kim-->
<form method="POST" action="index.php?app=b2c&ctl=admin_operator_member&act=editmsg" class="tableform" id="OPFORM">
<div class="tableform">
	<div class="division">
		<table>
		<{input type="hidden" value="{$msg.id}" name="id"}>
			<tbody>
				<tr>
					<th><em class="c-red">*</em><{t}>用户名：<{/t}></th>
					<td><{input type="text" name="operator[name]" size="20" style="width:200px" vtype="required" value="{$msg.name}"}></td>
				</tr>
				<{if $phones}>
				<tr>
					<th><em class="c-red">*</em><{t}>手机区号：<{/t}></th>
					<td>
						<select name="operator[phone_setting]" id="quhao" onchange="checkPerfix(this)">
							<{foreach from=$phones item=items}>
							<option sid="<{$items.length}>" value="<{$items.area}>" <{if $items.area == $msg.phone_setting}>selected="selected"<{/if}>><{$items.country}><{$items.area}></option>
							<{/foreach}>
						</select>
					</td>
				</tr>
				<{/if}>
				<tr>
					<th><em class="c-red">*</em><{t}>电话：<{/t}></th>
					<td><{input type="text" id="mobile" name="operator[tel]" style="width:200px" size="20" vtype="required" value="{$msg.tel}" onchange="telCheck(this)"}><span></span></td>
				</tr>
				<tr>
					<th><{t}>微信：<{/t}></th>
					<td><{input type="text" name="operator[wx_name]" size="20" style="width:200px" value="{$msg.wx_name}"}></td>
				</tr>
				<tr>
					<th><{t}>公司地址：<{/t}></th>
					<td>
					<{input app=ectools type="region"  name="operator[company_area]" vtype='area' value="{$msg.company_area}"}><span class="field_notice"></span>
					</td>
				</tr>
				<tr>
					<th>&nbsp;&nbsp;&nbsp;&nbsp; </th>
					<td>
					<{input  type="text"  name="operator[company_addr]" size="20" style="width:200px" value="{$msg.company_addr}"}></span>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</div>
<div class="table-action">
	<{button type="submit"  label=$___b2c="保存"|t:'b2c'}>
</div>
</form>
<script>
$('OPFORM').store('target',{
	onComplete:function(rs){
		var json;
		json = JSON.validate(rs) ? JSON.decode(rs) : null;
		if(json && json.success){
			window.close();
		}
		
//		if(opener.finderGroup['<{$env.get._finder.finder_id}>'])
//		opener.finderGroup['<{$env.get._finder.finder_id}>'].refresh();
//		window.close();
	}
});


function telCheck(input){
	var obj = $$("#quhao option:selected");
	var phone_setting = '';
	var len = '';
	if(obj && obj[0])
	{
		phone_setting = obj[0].value.replace("+","%2B");
		len = obj[0].get('sid');
	}

	new Request({
		url:'<{link app=b2c ctl=admin_operator_member act=check_tel}>',
		method:'post',
		data:'mobile='+input.value.trim()+"&phone_setting="+phone_setting+'&len='+len,
		onSuccess: function(rs) {
			rs = JSON.decode(rs);
			if(rs.error) {
				input.getNext().innerHTML = '<span class="error caution notice-inline">' +rs.error + '</span>';
			}
			else if(rs.success) {
				input.getNext().innerHTML = '<span class="success notice-inline">' +rs.success + '</span>';
			}
		}
	}).send();
}

function checkPerfix(obj){
	var phone_setting = obj.get('value');
	var input = $('mobile');
	var mobile = input.get('value');
	var o = $$("#quhao option:selected");
	if(o && o[0])
	{
		var len = o[0].get('sid');
	}
	new Request({
		url:'<{link app=b2c ctl=admin_operator_member act=check_tel}>',
		method:'post',
		data:'mobile='+mobile+"&phone_setting="+phone_setting+'&len='+len,
		onSuccess: function(rs) {
			rs = JSON.decode(rs);
			if(rs.error) {
				input.getNext().innerHTML = '<span class="error caution notice-inline">' +rs.error + '</span>';
			}
			else if(rs.success) {
				input.getNext().innerHTML = '<span class="success notice-inline">' +rs.success + '</span>';
			}
		}
	}).send();
}
</script>